/** 
 * 2011-10-10 下午05:50:09 
 * UdpChannelHandler.java 
 * author:sunb 
 */
package com.u6.udp.netty;

import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;

/**
 * @author sunbin
 * 
 */
public class UdpChannelHandler extends SimpleChannelUpstreamHandler {

	@Override
	public void messageReceived(ChannelHandlerContext handlerContext, MessageEvent e) throws Exception {
		Object object = e.getMessage();
		if (!(object instanceof UdpMessage)) {
			return;
		}
		UdpMessage message = (UdpMessage) object;
		UdpMessageDispatcher dispatcher = new UdpMessageDispatcher();
		dispatcher.dispatch(message, e);
	}

	@Override
	public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
		// TODO Auto-generated method stub
		super.exceptionCaught(ctx, e);
	}

}
